package day40;

// 发邮件
// 错发问题：
// D(n) = (n-1)* [D(n-2)+D(n-1)] n从3开始有效
// 注意：D(1)=0, D(2)=1

import java.util.Scanner;

public class Main1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {
            int n = in.nextInt();
            if(n>=2 && n<=20) {
                long[] ret = new long[21];
                ret[0] = 0;
                ret[1] = 0;
                ret[2] = 1;
                for (int i = 3; i <= n; i++) {
                    ret[i] = (i-1) * (ret[i-1]+ret[i-2]);
                }
                System.out.println(ret[n]);
            }
        }
    }
}
